<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>修改密码的验证</title>
</head>
<h1>修改密码</h1>
<b id="passModifyMess" style="color: red;"></b>
<form action="{{url_for('modify')}}" method="post">
<table border="1" cellpadding="0" width="20%">
<tr>
<td>新密码：</td>
<td><input type="password" name="newpass" id="newpass" placeholder="6-20位 数字字母下划线"/></td>
</tr>
<tr>
<td>确认密码：</td>
<td><input type="password" name="confirmpass" id="confirmpass" placeholder="与上面密码一致"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" id="submit" value="提交" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" id="reset" value="重置" />
</td>
</tr>
</table>
</form>

<body>
<script>
window.onload = function() {
var reset = document.getElementById('reset');
var fm = document.getElementsByTagName('form')[0];
var passModifyMess = document.getElementById('passModifyMess');
reset.onclick = function() {
newpass.value = '';
confirmpass.value = '';
newpass.focus();
};
fm.onsubmit = function() {
if(!/^[\w]{6,20}$/.test(newpass.value)) {
passModifyMess.innerHTML = "* 新密码不合法！";
newpass.value = '';
confirmpass.value = '';
newpass.focus();
return false;
}
if(newpass.value != confirmpass.value) {
passModifyMess.innerHTML = "* 两次输入的新密码不一致，请重新输入！";
newpass.value = '';
confirmpass.value = '';
newpass.focus();
return false;
}
// else{
// alert(newpass.value);
// var new=newpass.value;
// var xml = new XMLHttpRequest();
// xml.open("get","http://127.0.0.1:8080/modifypass/"+new,true);
// xml.send();
// alert("修改成功");
// return true;}
return true;
};
};
</script>
</body>
</html>